/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package 解析.node.node;


import 解析.Matcher;

/**
 *
 * @author yanxi
 */
public class GroupHead extends Node {  
    public int localIndex;
    public int groupIndex;

    public GroupHead(int localCount) {
        localIndex = localCount;  
    }
    
    @Override
    public boolean match(Matcher matcher, int i, CharSequence seq) {
        int save = matcher.locals[localIndex];
        matcher.locals[localIndex] = i;
        boolean ret = next.match(matcher, i, seq);
        matcher.locals[localIndex] = save;
        return ret;
    }

    boolean matchRef(Matcher matcher, int i, CharSequence seq) {
        int save = matcher.locals[localIndex];
        matcher.locals[localIndex] = ~i; // HACK
        boolean ret = next.match(matcher, i, seq);
        matcher.locals[localIndex] = save;
        return ret;
    } 
    
}
